package com.hello.web.controller;


import com.hello.common.aspect.ApiOperationLog;
import com.hello.common.utils.Response;
import com.hello.web.domain.bo.permission.PermissionQueryBO;
import com.hello.web.domain.bo.permission.PermissionUpdateBO;
import com.hello.web.service.permission.PermissionService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/permission")
@RequiredArgsConstructor
public class PermissionController {

    private final PermissionService permissionService;


    @PostMapping("/roleId/list")
    @ApiOperation(value = "角色权限列表")
    @ApiOperationLog(description = "角色权限列表")
    public Response queryPermissionByRoleId(@RequestBody @Validated PermissionQueryBO bo) {
        return permissionService.queryPermissionByRoleId(bo);
    }

    @PostMapping("/list")
    @ApiOperation(value = "权限列表")
    @ApiOperationLog(description = "权限列表")
    public Response queryPermissionList() {
        return permissionService.queryPermissionList();
    }


    @PostMapping("/roleId/update")
    @ApiOperation(value = "修改角色权限")
    @ApiOperationLog(description = "修改角色权限")
    public Response updatePermissionByRoleId(@RequestBody @Validated PermissionUpdateBO bo) {
        return permissionService.updatePermissionByRoleId(bo);
    }

    @PostMapping("/menu/list")
    @ApiOperation(value = "菜单列表")
    @ApiOperationLog(description = "菜单列表")
    public Response queryMenuList() {
        return permissionService.queryMenuList();
    }

    @PostMapping("/tree/list")
    @ApiOperation(value = "菜单树")
    @ApiOperationLog(description = "菜单列表")
    public Response queryTreeList() {
        return permissionService.queryTreeList();
    }

    @PostMapping("/roleId/tree/list")
    @ApiOperation(value = "角色菜单树")
    @ApiOperationLog(description = "菜单列表")
    public Response queryRoleIdTreeList(@RequestBody @Validated PermissionQueryBO bo) {
        return permissionService.queryRoleIdTreeList(bo);
    }

}
